<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8"/>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="viewport"
          content="user-scalable=no, width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, maximum-scale=1.0 "/>
    <title><yang:sitetitle/></title>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/global.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/about/recruitment.css"/>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.10.1.min.js"></script>

    <script src="__PUBLIC__/js/jquery-html5Validate.js"></script>
    <script src="__PUBLIC__/js/jquery.form.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery-hcheckbox.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/global.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/ajaxupload.js"></script>

    <script type="text/javascript" src="__PUBLIC__/js/about/recruitment.js"></script>


</head>

<!--[if lt IE 10]>
<script type="text/javascript" src="pie.js"></script>
<![endif]-->

<body>


<include file="Public:header"/>
<div class="section">
    <include file="Public:column"/>
    <div class="content clearfix">
        <div class="col_sidebar">
            <ul>
                <volist name="left_menu" id="catlist">
                    <li <if condition="$catlist['id'] eq $third_cat['id']">class="act"</if>><a href="{$catlist|get_url}">{$catlist.name}</a></li>
                </volist>
            </ul>
        </div>
        <div class="col_con">
            <div class="con_title">
                <img src="__PUBLIC__/images/title_icon4.png"/>
                <h2>人才招聘</h2>
            </div>
            <div class="hint">注：可勾选下述心仪的岗位，最多不可超过三个岗位</div>

            <form id="form_job" method="post" enctype="multipart/form-data">

                <ul class="job">
                    <volist name="list" id="vo">
                    <li>
                        <dl>
                            <dd class="til">
                                <input name="check[]" type="checkbox" value="{$vo.id}" class="checkboxFiveInput"
                                       id="chk{$vo.id}"}/><label for="chk{$vo.id}"></label>{$vo.title}
                            </dd>
                            <dd class="city">{$vo.site}</dd>
                            <dd class="num">{$vo.number}人</dd>
                            <dd class="icon"><em></em></dd>
                        </dl>
                        <div class="sub_text">
                            <h3>职位描述：</h3>
                            {$vo.description}
                            <h3>任职要求：</h3>
                            {$vo.requirements}
                        </div>
                    </li>
                    </volist>
                </ul>
                <div class="clear"></div>
                <div class="form_list">
                    <ul>
                        <li class="clearfix"><span>姓　　名</span><input id="name" name="name" type="text"
                                                                     placeholder="请填写真实姓名" maxlength="20" required/>
                        </li>
                        <li class="clearfix"><span>手 机 号</span><input id="phone" name="phone" type="tel"
                                                                      placeholder="请填写有效手机号" required/></li>
                        <li class="clearfix"><span>邮　　箱</span><input id="email" name="email" type="email"
                                                                     placeholder="请填写有效邮箱" required/></li>
                        <li class="clearfix"><em>预约面试</em><input type="radio" name="radio_group" value="1"
                                                                 class="radio_one" checked="checked"
                                                                 id="radio_1"/><label for="radio_1">随时</label><input
                                type="radio" name="radio_group" value="2" id="radio_2"/><label
                                for="radio_2">一周之内</label><input type="radio" name="radio_group" value="3"
                                                                 id="radio_3"/><label for="radio_3">一个月之内</label></li>
                        <li class="selected_job clearfix"><em>竞聘岗位</em></li>

                        <li class="clearfix last_li"><em>上传简历</em> <a href="javascript:void(0);" class="upload">
                            <img src="__PUBLIC__/images/about/reciurtment_icon1.png"/>本地上传<input type="file" name="imgFile"
                                                                                         id="imgFile"></a>
                            <button id="submit" class="confirm" type="submit" name="submit">
                                <img src="__PUBLIC__/images/about/reciurtment_icon2.png"/>确认发送
                            </button>
                        </li>
                        <li class="clearfix" style="height: 25px; line-height: 25px;"><em></em>请上传后缀名为.doc,.docx,.pdf简历文件
                        </li>
                        <li class="clearfix" id="lifile" style="height: 25px; line-height: 25px;"></li>
                        <input type="hidden" name="fileurl" value="" id="fileurl">
                    </ul>
                </div>
            </form>
        </div>
    </div>
</div>

<include file="Public:footer"/>
<div class="return_top">
    <a href="javascript:void(0);"></a>
</div>
</body>
</html>
<script type="text/javascript">
    // $("#submit").click(function () {    $("#form_job").submit();});

    $("#form_job").html5Validate(function () {
                $("#submit").attr({"disabled": "disabled"});
                var options = {
                    url: '{:U("Index/applyJob")}',
                    type: 'post',
                    success: function (data) {
                        if (data == "ok" || data == "<PRE>ok</PRE>") {
                            alert("提交成功，请耐心等待管理员审核");
                            window.location.reload();
                        } else {
                            alert("提交失败，请稍后再试");
                        }
                        $("input[name='imgFile']").val("");
                        $("#lifile").html("");
                        $("#submit").removeAttr("disabled");
                    }
                };
                $("#form_job").ajaxSubmit(options);
            },
            {
                validate: function () {
                    var chkid = "";
                    var icount = 0;
                    $(".job input[type=checkbox]").each(function (index, element) {

                        if ($(this).is(":checked")) {
                            icount++;
                            chkid += $(this).val() + ",";
                        }
                    });
                    if (chkid == "") {
                        $("input[type='checkbox']").testRemind("请至少选择一个岗位");
                        $("input[type='checkbox']").focus();
                        return false;
                    }
                    if (icount > 3) {
                        $("input[type='checkbox']").testRemind("最多只能选择三个岗位");
                        $("input[type='checkbox']").focus();
                        return false;
                    }
                    if ($("input[name='fileurl']").val() == "") {
                        $("input[name='imgFile']").testRemind("请上传简历");
                        $("input[name='imgFile']").focus();
                        return false;
                    }
                    return true;
                }
            }
    );

    // 创建一个上传参数
    var uploadOption =
    {
        // 提交目标
        action: "{:U('Index/upload')}",
        // 服务端接收的名称
        name: "file",
        // 自动提交
        autoSubmit: false,
        // 选择文件之后…
        onChange: function (file, extension) {
            if (new RegExp(/(doc)|(docx)|(pdf)/i).test(extension)) {
                $("#lifile").val(file);
            } else {
                alert("只限上传图片文件，请重新选择！");
            }
        },
        // 开始上传文件
        onSubmit: function (file, extension) {
            $("#lifile").val("正在上传" + file + "..");
        },
        // 上传完成之后
        onComplete: function (file, response) {
            response = JSON.parse(response);
            console.log(33333, response);
            if (response.state) {
                $("#lifile").html("<em></em>"+file);
                $("#fileurl").val(response.url);
            }
            else {
                $("#lifile").html("<em></em>"+response.info);
            }
            $("#imgFile").replaceWith('<input type="file" name="imgFile" id="imgFile">');
            $("#imgFile").change(function(){
                oAjaxUpload.submit();
            })
        }
    }

    // 初始化图片上传框
    var oAjaxUpload = new AjaxUpload('#imgFile', uploadOption);

    // 初始化图片上传框

    $("input[name='file']").change(function () {
            oAjaxUpload.submit();
    });


</script>
